package com.yty.demo._4_oop;

/**
 * @author: yangtaoyao
 * @time: 2020/1/7 15:54
 * @description: 继承
 */
 class ManKind {
    private int sex;
    private int salary;
    public int publicInt;

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public void manOrWoman(){
        System.out.println(this.sex==1?"man":"woman");
    }
    protected void employee(){
        System.out.println(this.salary==0?"no job":"job");
    }
}

public class Kids extends ManKind implements writer{
    private int yearsOld;
    public String hobby;

    public Kids(int yearsOld) {
        super();
        //this();//调用super()则不能调用this()
        this.yearsOld = yearsOld;
    }

    public Kids() {
    }

    private void privateM(){
        System.out.println("privateM()");
    }

    public int getYearsOld() {
        return yearsOld;
    }

    private void yearsOld(){
        System.out.println("...yearsOld()");
    }

    public void setYearsOld(int yearsOld) {
        this.yearsOld = yearsOld;
    }

    public void printAge(){
        System.out.println(this.yearsOld);
    }

    //重写
    @Override
    public void employee() {
        System.out.println("kid employee()");
    }

    public static void main(String[] args) {
        Kids someKid=new Kids();
        someKid.setSalary(0);
        someKid.setSex(1);
        someKid.manOrWoman();
        someKid.employee();
    }

    @Override
    public void write() {
        System.out.println("...write()");
    }
}

interface writer{
     void write();
}
